#ifndef creole_regex_result_guard
#define creole_regex_result_guard

#include <string>
#include <vector>
#include <iostream>
#include "regex_base.h"
#include "seq.h"

class match_result;
std::ostream& operator<<(std::ostream&,const match_result&);

struct ref_pair
{
    ref_pair(std::size_t a,std::string b) : size(a), what(b) {}
    size_t size;
    std::string what;
};
std::ostream& operator<<(std::ostream&,const ref_pair&);

class match_result
{
	bool matched;
	size_t length;
    std::vector<std::string> backref;

    friend class seq;
	friend class regex;
	friend std::ostream& operator<<(std::ostream&,const match_result&);

	public:
		match_result() : matched(false), length(0) {}
		bool get_matched() { return matched;}
		int  get_length()  { return length;}
		match_result(bool a,int b) : matched(a), length(b) {}

        operator bool() {return matched;}
        ref_pair get(size_t S); //get the backreference at S
        size_t ref_count() {return backref.size();}
};

#endif
